﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OF.Component.BLL;
using OF.Component.Model;
using OF.Utility;
using OpSystem.common;

namespace OpSystem.manage.authority
{
    public partial class AuthoritysystemAdd : BasePage
    {
        protected int intID {
            get {
                return RequestUtility.GetQueryInt("ID", -1);
            }
        }

        protected string strMessage = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (intID > -1)
                {
                    AuthoritySystemInfo info = AuthoritySystemOperate.GetByID(intID);
                    this.txtName.Text = info.SystemName;
                    this.txtCode.Text = info.SystemCode;
                    this.txtNum.Text = info.OrderNum.ToString();
                    this.txtRemark.Text = info.Remark.ToString();
                    this.txtUrl.Text = info.SystemUrl;

                }
               
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string MessageInfo = "信息修改成功！";
            AuthoritySystemInfo info = AuthoritySystemOperate.GetByID(intID);
            if (info == null)
            {
                info = new AuthoritySystemInfo();

            }
           // AuthorityMenuInfo oldinfo = ObjectCopy<AuthorityMenuInfo>.DeepCopy(info);
            info.SystemName = txtName.Text;
            info.SystemCode = txtCode.Text;
            info.OrderNum = EConvert.ToInt(txtNum.Text);
            info.Remark = txtRemark.Text;
            info.IsActive = 1;
            info.UpdateTime = DateTime.Now;
            info.SystemUrl = txtUrl.Text;
            if (intID > 0)
            {
                AuthoritySystemOperate.Update(info);
                //  OpOperationLogOperate.SetLog(oldinfo, info, OpUserID, OpUserInfo.OpUserName, (short)LogType.OpMenuManage, info.MenuID);
            }
            else
            {
                MessageInfo = "信息创建成功！";
                info.CreatedDate = DateTime.Now;
                AuthoritySystemOperate.Insert(info);
                //  OpOperationLogOperate.SetLog(null, info, OpUserID, OpUserInfo.OpUserName, (short)LogType.OpMenuManage, info.MenuID);
            }
            strMessage = " BMCW.msg(\"" + MessageInfo + "\",\"" + GetPageUrl("Authoritysystem.aspx") + "\",true);";
        }
    }
}